﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MadPropsDemo.RecipeEditor;

namespace MadPropsDemo.Tests.RecipeEditorTests
{
    [TestClass]
    public class the_IngredientSummary_is_updated_when : RecipeEditorTestBase
    {
        MadProps.Testability.PropChangeRecorder recorder;

        protected override void OnSetup()
        {
            base.OnSetup();

            recorder = new MadProps.Testability.PropChangeRecorder();
            recorder.Subscribe(viewModel);
        }

        int ChangeCount { get { return recorder.ChangeCountFor(viewModel.IngredientSummary); } }

        [TestMethod]
        public void the_selected_ingredient_Name_changes()
        {
            SelectedIngredient.Name.Value = "dsdfs";
            Assert.AreEqual(1, ChangeCount);
        }

        [TestMethod]
        public void the_selected_ingredient_Quantity_changes()
        {
            SelectedIngredient.Quantity.Value = 634;
            Assert.AreEqual(1, ChangeCount);
        }

        [TestMethod]
        public void the_selected_ingredient_UnitOfMeasure_changes()
        {
            SelectedIngredient.UnitOfMeasure.Value = "fjkd9";
            Assert.AreEqual(1, ChangeCount);
        }

        [TestMethod]
        public void the_Recipe_changes()
        {
            viewModel.TheRecipe = new Recipe();
            Assert.AreEqual(1, ChangeCount);
        }

        [TestMethod]
        public void the_CustomScaleFactor_changes()
        {
            viewModel.CustomScaleFactor.Value = 3.44M;
            Assert.AreEqual(1, ChangeCount);
        }
    }
}
